<?php


namespace app\common\model;


use think\Model;

class Content extends Model
{
    public function insertDate($data){
        $result = $this->save($data);
        return $result;
    }
    public function getList($order=''){
        if(empty($order)){
            $result = $this->order($order,'asc')->select();
        }else{
            $result = $this->select();
        }
        $result = $this->select();
        return $result;
    }
    public function getDetail($id){
        $where = [
            "id"=>$id
        ];
        $result = $this->where($where)->find();
        return $result;
    }
    public function updateContent($id,$data){
        $where = [
            "id"=>$id,
        ];
        $result = $this->where($where)->save($data);
        return $result;
    }
    public function remove($id){
        $where = [
            'id'=>$id
        ];
        $result = $this->where($where)->delete();
        return $result;
    }
    public function changeSort($id,$data){
        $where = [
            "id"=>$id,
        ];
        $result = $this->where($where)->save($data);
        return $result;
    }
    //前台调用
    public function getAllList(){
        $result = $this->order('sort','desc')->select();
        return $result;
    }
}